package com.example.mytestdemo

import android.os.Bundle
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.example.mytestdemo.databinding.BaseActivityStatusBinding


/**
 * @author tgw
 * @date 2021/6/10
 * @describe
 */
abstract class BaseViewBindActivity<VB : ViewDataBinding> : AppCompatActivity() {

    companion object {
        const val TAG = "BaseViewBindActivity"
    }


    private lateinit var mBaseBind: BaseActivityStatusBinding

    protected lateinit var mBind: VB
    protected lateinit var mFlLoadingView: FrameLayout


    abstract fun getLayoutInflateId(): Int


    abstract fun initData()

    abstract fun initUI()

    open fun networkChanged(available: Boolean) {

    }


    override fun onCreate(savedInstanceState: Bundle?) {
//        window.setBackgroundDrawable(getDrawable(R.drawable.splash_wpt_img))

//        setTheme(R.style.ActivitySplash2)

        super.onCreate(savedInstanceState)
//        Handler().postDelayed({
            mBaseBind = DataBindingUtil.setContentView(
                this,
                R.layout.base_activity_status
            )

            mBind = DataBindingUtil.inflate(
                layoutInflater,
                getLayoutInflateId(),
                mBaseBind.flContainer,
                true
            )
            mFlLoadingView = mBaseBind.flLoading
            initUI()
            initData()
//        },0)



    }


    override fun onDestroy() {
        mBaseBind.unbind()
        super.onDestroy()
    }
}